package chen.controller;

import chen.entity.Emp;
import chen.service.EmpService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * (Emp)表控制层
 *
 * @author makejava
 * @since 2021-07-30 16:44:54
 */
@RestController
@RequestMapping("emp")
public class EmpController {
    /**
     * 服务对象
     */
    @Resource
    private EmpService empService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Emp selectOne(Integer id) {
        return this.empService.queryById(id);
    }

    @RequestMapping("add")
    public Map<String, Object> insert(Emp emp){
        Emp insert = empService.insert(emp);
        System.out.println(insert);
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 1);
        map.put("data", 1);
        return map;
    }

}